#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int judge(int year)
{
	if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
	{
		return 1;
	}
	else
		return 0;
}
int main()
{
	int year, month, day;
	scanf("%d%d%d", &year, &month, &day);

	int arr1[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
	int arr2[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };

	if (judge(year))
	{
		int days = 0;
		for (int i = 0; i < month - 1; i++)
		{
			days += arr2[i];
		}
		printf("%d", days + day);
	}
	else
	{
		int days = 0;
		for (int i = 0; i < month - 1; i++)
		{
			days += arr1[i];
		}
		printf("%d", days + day);
	}

	return 0;
}